package com.beordie.control;

import com.beordie.model.Grade;
import com.beordie.service.IGradeService;
import com.beordie.service.impl.GradeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @Classname GradeController
 * @Description 年级信息相关请求的处理类
 * @Date 2021/6/10 12:34
 * @Created 30500
 */
@WebServlet(urlPatterns = "/Educational/student/grade")
public class GradeController extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 获取数据库的所有班级信息
        IGradeService service = new GradeServiceImpl();
        List<Grade> list = null;
        try {
            list = service.getAll();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        req.setAttribute("grades", list);
        req.getRequestDispatcher("add.jsp").forward(req, resp);
    }
}
